#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright: (c)  : @Time 2025/3/29 14  @Author  : hjl
# @Site    : 
# @File    : test.py
# @Project: alibaba_spider
# @Software: PyCharm
# @Desc    :
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

import requests
from lxml import etree

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0",
}


# product_link_html = self.get_html(product_link)
# print(product_link_html)
# parser = etree.HTMLParser(encoding="utf-8")
# selector = etree.HTML(product_link_html, parser=parser)
# page_nums = selector.xpath(
#     '//*[@id="radix-:r9:-content-company"]/div/div[5]/div//button[contains(@data-spm-anchor-id, "1")]/text()')[
#     0]

def get_html(url):
    try:
        response = requests.get(url, headers=headers)
        html = response.text
    except Exception as e:
        return None
    return html


product_link_html = "https://chinese.alibaba.com/product-detail/Touchable-Core-I9-Design-for-High_1601336476173.html"
print(product_link_html)
html = get_html(product_link_html)
print(html)
parser = etree.HTMLParser(encoding="utf-8")
selector = etree.HTML(product_link_html, parser=parser)
